package com.sky.mapper;

import com.sky.entity.DishFlavor;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface DishFlavorMapper {

    /**
     * 批量插入口味信息
     * DishFlavor包含口味信息和菜品id
     * @param flavors
     * @author Mr.Chen
     * @create 2025/3/24
     **/
    void insertBatch(List<DishFlavor> flavors);


    /**
     *
     * 根据菜品id删除对应口味信息
     * @param id
     * @author Mr.Chen
     * @create 2025/3/24
     **/
    @Delete("delete from dish_flavor where dish_id = #{id}")
    void deleteByDishId(Long id);

    /**
     *
     * 根据菜品id批量删除口味信息
     * @param dishIds
     * @author Mr.Chen
     * @create 2025/3/24
     **/
    void deleteBatchByDishIds(List<Long> dishIds);


    @Update("update dish_flavor set name = #{name},value = #{value} where dish_id = #{dishId}")
    void update(DishFlavor flavor);

    @Select("select * from dish_flavor where dish_id = #{dishId}")
    List<DishFlavor> getByDishId(Long dishId);
}
